<!doctype html>

<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>Custom editor in the lightbox</title>

	<script src="../../codebase/dhtmlxscheduler.js?v=5.3.10" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" href="../../codebase/dhtmlxscheduler_material.css?v=5.3.10" type="text/css" charset="utf-8">

	<style type="text/css">
		html,
		body {
			margin: 0;
			padding: 0;
			height: 100%;
			overflow: hidden;
		}

		.dhx_cal_ltext.my_editor {
			position: relative;
			top: -2px;
		}

		.dhx_cal_ltext.my_editor {
			line-height: 40px;
		}

		.dhx_cal_ltext.my_editor input {
			width: 271px;
			padding-left: 8px;
			box-sizing: border-box;
			height: 33px;
			text-overflow: ellipsis;
		}

		.dhx_cal_ltext.my_editor input:first-child {
			margin: 0 0 0 20px;
			border-bottom: 0;
		}
	</style>

	<script type="text/javascript" charset="utf-8">
		function init() {
			scheduler.config.details_on_dblclick = true;
			scheduler.config.details_on_create = true;
			scheduler.init('scheduler_here', new Date(2018, 2, 1), "week");

			scheduler.form_blocks["my_editor"] = {
				render: function (sns) {
					return "<div class='dhx_cal_ltext' style='height:60px;'>" +
						"Text&nbsp;<input name='text' type='text'><br/>" +
						"Details&nbsp;<input name='location' type='text'></div>";
				},
				set_value: function (node, value, ev) {
					node.querySelector("[name='text']").value = value || "";
					node.querySelector("[name='location']").value = ev.location || "";
				},
				get_value: function (node, ev) {
					ev.location = node.querySelector("[name='location']").value;
					return node.querySelector("[name='text']").value;
				},
				focus: function (node) {
					var input = node.querySelector("[name='text']");
					input.select();
					input.focus();
				}
			};

			scheduler.locale.labels.section_description = "Details";
			scheduler.config.lightbox.sections = [
				{ name: "description", map_to: "text", type: "my_editor", focus: true },
				{ name: "time", height: 72, type: "time", map_to: "auto" }
			];

			scheduler.load("../common/events.json", function () {
				scheduler.showLightbox("1261150564");
			});
		}
	</script>
</head>

<body onload="init();">
	<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
		<div class="dhx_cal_navline">
			<div class="dhx_cal_prev_button">&nbsp;</div>
			<div class="dhx_cal_next_button">&nbsp;</div>
			<div class="dhx_cal_today_button"></div>
			<div class="dhx_cal_date"></div>
			<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
			<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
			<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
		</div>
		<div class="dhx_cal_header">
		</div>
		<div class="dhx_cal_data">
		</div>
	</div>
</body>